package com.iapp.controller;

import com.iapp.po.AdminUser;
import com.iapp.po.Result;
import com.iapp.service.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wrh
 */
@RestController
@RequestMapping("adminUser")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;

    @PostMapping("doLogin")
    @ResponseBody
    public Result login(HttpServletRequest request,String adminName,String adminPass){
        Result result=adminUserService.getAdminUserByName(adminName,adminPass);
        if(result.getCode()==200){
            request.getSession().setAttribute("adminUser",result.getData());
            return result;
        }
        return result;
    }
    @PostMapping("doRegister")
    @ResponseBody
    public Result register(AdminUser adminUser){
        return adminUserService.insertAdminUser(adminUser);
    }

}
